#!/bin/bash  
while getopts :p:c:a:b:r:d:e:o:s:n:z:x:g:l:j:h:m:t:i:q:w: ARGS
do
case $ARGS in
    p)
        primary=$OPTARG
        ;;
	b)
        buttonBorderRadiusBase=$OPTARG
        ;;
	r)
        borderRadiusBase=$OPTARG
        ;;
	c)
        primary90=$OPTARG
        ;;
	a)
        primary15=$OPTARG
        ;;
	d)
        primary60=$OPTARG
        ;;
	e)
        primary10=$OPTARG
        ;;		
	o)
        blackColor=$OPTARG
        ;;		
	s)
        lightGrayColor2=$OPTARG
        ;;
	n)
        grayColor=$OPTARG
        ;;
	z)
        darkGray=$OPTARG
		;;
	x)
        errColor=$OPTARG
        ;;
	g)
        lightGray=$OPTARG
        ;;
	l)
        link=$OPTARG
        ;;
	j)
        success=$OPTARG
        ;;
	h)
        shadow=$OPTARG
        ;;
	m)
        ptz=$OPTARG
        ;;
	t)
       theme=$OPTARG
        ;;
	i)
        input=$OPTARG
        ;;
	q)
        login=$OPTARG
        ;;
	w)
        wechat=$OPTARG
        ;;
esac
done
root=$(cd `dirname $0`; pwd)
echo "primary90 dd" ${primary90}
resources=${root}/src/main/res/values/customize.xml
echo $resources
if [ $primary ]; then
	echo $primary
	${root}/../module_resources_replace.sh global_customize_main_color ${primary}  ${resources}
	${root}/../module_resources_replace.sh global_customize_fixed_global_rounded_button_end_color ${primary}  ${resources}
	transparent10=\#1A${primary//#/}
transparent30=\#4D${primary//#/}
echo transparent30
${root}/../module_resources_replace.sh global_customize_fixed_global_button_shadow_color ${transparent30}  ${resources}
${root}/../module_resources_replace.sh global_customize_main_color_30 ${transparent30}  ${resources}
fi
if [ $primary90 ]; then
	echo $primary90
	${root}/../module_resources_replace.sh global_customize_main_color_90 ${primary90}  ${resources}
	${root}/../module_resources_replace.sh global_customize_fixed_global_rounded_button_start_color ${primary90}  ${resources}
fi
if [ $primary60 ]; then
	echo $primary60
	${root}/../module_resources_replace.sh global_customize_main_color_60 ${primary60}  ${resources}
fi
if [ $primary15 ]; then
	echo $primary15
	${root}/../module_resources_replace.sh global_customize_main_color_15 ${primary15}  ${resources}
fi
if [ $primary10 ]; then
	echo $primary10
	${root}/../module_resources_replace.sh global_customize_main_color_10 ${primary10}  ${resources}
fi
if [ $borderRadiusBase ]; then
	echo $borderRadiusBase
	${root}/../module_resources_replace.sh global_customize_fixed_global_rounded_radius ${borderRadiusBase}dp  ${resources}
fi

if [ $buttonBorderRadiusBase ]; then
	echo $buttonBorderRadiusBase
	${root}/../module_resources_replace.sh global_customize_fixed_global_button_rounded_radius ${buttonBorderRadiusBase}dp  ${resources}
fi

if [ $blackColor ]; then
	echo $blackColor
	${root}/../module_resources_replace.sh global_customize_fixed_color_black ${blackColor}  ${resources}
fi
if [ $lightGrayColor2 ]; then
	echo $lightGrayColor2
	${root}/../module_resources_replace.sh global_customize_fixed_color_light_gray2 ${lightGrayColor2}  ${resources}
fi
if [ $grayColor ]; then
	echo $grayColor
	${root}/../module_resources_replace.sh global_customize_fixed_color_gray ${grayColor}  ${resources}
	transparent30=\#4D${grayColor//#/}
	${root}/../module_resources_replace.sh global_customize_fixed_color_gray_30 ${transparent30}  ${resources}
fi
if [ $errColor ]; then
	${root}/../module_resources_replace.sh global_customize_fixed_color_error ${errColor}  ${resources}
fi
if [ $lightGray ]; then
	${root}/../module_resources_replace.sh global_customize_fixed_color_light_gray ${lightGray}  ${resources}
fi
if [ $link ]; then
	${root}/../module_resources_replace.sh global_customize_fixed_color_link ${link}  ${resources}
fi
if [ $success ]; then
	${root}/../module_resources_replace.sh global_customize_fixed_color_correct ${success}  ${resources}
fi
if [ $shadow ]; then
	shadowFc=\#FC${shadow//#/}
	${root}/../module_resources_replace.sh global_customize_fixed_color_shadow ${shadowFc}  ${resources}
fi

resources_layout=${root}/src/main/res/values/customize_layout.xml

if [[ $theme =~ "standard" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_style 0  ${resources_layout}
elif [[ $theme =~ "background" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_style 1  ${resources_layout}
fi

# 微信样式
if [[ $wechat =~ "whiteGradient" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_wechat_style 0  ${resources_layout}
elif [[ $wechat =~ "greenFill" ]];then	
  ${root}/../module_resources_replace.sh layout_tange_global_login_page_wechat_style 1  ${resources_layout}
elif [[ $wechat =~ "fill" ]];then	
 	 ${root}/../module_resources_replace.sh layout_tange_global_login_page_wechat_style 0  ${resources_layout}
elif [[ $wechat =~ "stroke" ]];then	
 	 ${root}/../module_resources_replace.sh layout_tange_global_login_page_wechat_style 1  ${resources_layout}
fi

echo $login
if [[ $login =~ "standard" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_button_style 0 ${resources_layout}
elif [[ $login =~ "arrow" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_button_style 1 ${resources_layout}
fi
if [[ $input =~ "concise" ]];then
	echo $input
	${root}/../module_resources_replace.sh layout_tange_global_login_page_edit_text_style 0 ${resources_layout}
elif [[ $input =~ "iconConcise" ]];then
	echo $input
	${root}/../module_resources_replace.sh layout_tange_global_login_page_edit_text_style 1 ${resources_layout}
elif [[ $input =~ "line" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_edit_text_style 0 ${resources_layout}
elif [[ $input =~ "backgroundColor" ]];then
	${root}/../module_resources_replace.sh layout_tange_global_login_page_edit_text_style 1 ${resources_layout}
fi

if [ $ptz ]; then
cp -r ${root}/customize/${ptz}/* ${root}/src/main/res
rm -rf ${root}/customize
fi